package autorization;

    /**
     * Class specialised for storage in reference data structures
     * system the identifier of the user
     * @author Volk ID = 1001
     */
    class LongComparable implements Comparable<LongComparable>{
        // The constant which is stipulated inadmissible value of the identifier
        public final int ERROR_VALUE = -1;
        public long value = ERROR_VALUE;  //system identifier of user

        /**
         * constructor
         * @param value - system identifier of user
         */
        public LongComparable(long value){
         this.value = value;
        }

        /**
         * compare of two objectes, having type LongComparable
         * compare of using data structure, which use compare
         * operations, defined in interface Comparable
         * @param op - The second operand participating in matching operation
         * @return 0 - operands are equals;
         *         -1 - first operand less than second;
         *          1 - first operand less than second;
         */
        @Override
        public int compareTo(LongComparable op) {
          if(value == op.value) return 0;
          if(value < op.value) return -1;
          return 1;
        }
        /**
         * comparing of two objects on equal
         * @param arg - the second operator of comparing
         * @return true - object equals, false - not equals
         */
        @Override
        public boolean equals(Object arg) {
          if(this == arg) return true;
          if(arg == null) return false;
          if(getClass() != arg.getClass()) return false;
          LongComparable object = (LongComparable)arg;
          return value == object.value?true:false;
        }
        /**
         * Reception of a hash-code of the object, used as the identifier
         * the given object
         * @return an object hash-code
         */
        @Override
         public int hashCode() {
          return (int)value;
         }
        }


  //---------------------------------------------------------------------------